import { View, Button } from "@tarojs/components";
import { useLoad, useRouter } from "@tarojs/taro";
import { fetchDetail } from "../../utils/api";

// 获取详情ID， 请求详情接口
const DetailPage = () => {
  // 获取路由信息
  const router = useRouter();

  // 详情接口
  const fetchDetailData = async (id: string) => {
    const detailRes = await fetchDetail({ id });
    console.log("detailRes:", detailRes);
  };

  useLoad(() => {
    const id = router.params?.id;
    if (id) {
      fetchDetailData(id);
    }
  });

  return (
    <View>
      DetailPage
      <Button>按钮</Button>
    </View>
  );
};

export default DetailPage;
